package designPattern.observer.asynchronous;

import designPattern.observer.asynchronous.event.ObserverEvent;
import designPattern.observer.asynchronous.observer.Observer;
import designPattern.observer.asynchronous.observer.ObserverA;
import designPattern.observer.asynchronous.observer.ObserverB;

public class DoService {

	private Observable observable = new Observable();
	private Observer observerA = new ObserverA();
	private Observer observerB = new ObserverB();

	public DoService() {
		observable.addObserver(observerA);// 添加观察者
		observable.addObserver(observerB);// 添加观察者
	}

	public void doAction() {
		System.out.println("异步处理-->DoService:"+Thread.currentThread().getName()+";进行逻辑处理开始");
		observable.notifyObservers(new ObserverEvent());
		System.out.println("异步处理-->DoService:"+Thread.currentThread().getName()+";进行逻辑处理结束");
	}
}
